package com.baoteng.liteorm;

import android.content.Context;

import com.litesuits.orm.db.assit.QueryBuilder;
import com.litesuits.orm.db.assit.WhereBuilder;

import java.util.HashMap;
import java.util.List;

/**
 * Author: loren
 * Date: 2019/8/12
 */
public class LiteOrmProxy implements IDatabase {

    private IDatabase database;

    public static LiteOrmProxy getInstance() {
        return InstanceHolder.instance;
    }

    private static class InstanceHolder {
        static final LiteOrmProxy instance = new LiteOrmProxy();
    }

    public LiteOrmProxy() {
        database = LiteOrmDBManager.getInstance();
    }

    @Override
    public void init(Context context) {
        database.init(context);
    }

    @Override
    public boolean isDBManagerInitSuccess() {
        return database.isDBManagerInitSuccess();
    }

    @Override
    public void initCascade(Context context) {
        database.initCascade(context);
    }

    @Override
    public <T> long save(T t) {
        return database.save(t);
    }

    @Override
    public <T> long saveAll(List<T> list) {
        return database.saveAll(list);
    }

    @Override
    public <T> long insert(T t) {
        return database.insert(t);
    }

    @Override
    public <T> long insert(List<T> list) {
        return database.insert(list);
    }

    @Override
    public <T> long update(T t) {
        return database.update(t);
    }

    @Override
    public <T> long update(T t, HashMap<String, Object> changeEntityMap) {
        return database.update(t, changeEntityMap);
    }

    @Override
    public long update(WhereBuilder whereBuilder, HashMap<String, Object> changeEntityMap) {
        return database.update(whereBuilder, changeEntityMap);
    }

    @Override
    public <T> long update(List<T> list) {
        return database.update(list);
    }

    @Override
    public <T> long delete(T t) {
        return database.delete(t);
    }

    @Override
    public <T> long delete(List<T> list) {
        return database.delete(list);
    }

    @Override
    public <T> long delete(Class<T> clazz) {
        return database.delete(clazz);
    }

    @Override
    public <T> long deleteAll(Class<T> clazz) {
        return database.deleteAll(clazz);
    }

    @Override
    public <T> T queryById(long id, Class<T> clazz) {
        return database.queryById(id, clazz);
    }

    @Override
    public <T> T queryById(String id, Class<T> clazz) {
        return database.queryById(id, clazz);
    }

    @Override
    public <T> List<T> queryAll(Class<T> clazz) {
        return database.queryAll(clazz);
    }

    @Override
    public <T> List<T> queryByWhere(Class<T> clazz, String field, String value) {
        return database.queryByWhere(clazz, field, value);
    }

    @Override
    public <T> List<T> queryByWhere(Class<T> clazz, String[] fields, String[][] values) {
        return database.queryByWhere(clazz, fields, values);
    }

    @Override
    public <T> List<T> queryByWhere(Class<T> clazz, QueryBuilder<T> queryBuilder) {
        return database.queryByWhere(clazz, queryBuilder);
    }

    @Override
    public <T> List<T> queryByWhere(Class<T> clazz, String field, String[] value, int start, int length) {
        return database.queryByWhere(clazz, field, value, start, length);
    }

    @Override
    public <T> List<T> queryLimit(Class<T> clazz, int start, int length) {
        return database.queryLimit(clazz, start, length);
    }

    @Override
    public <T> List<T> queryData(QueryBuilder<T> queryBuilder) {
        return database.queryData(queryBuilder);
    }

    @Override
    public <T> long queryCount(Class<T> clazz) {
        return database.queryCount(clazz);
    }

    @Override
    public boolean deleteDatabase() {
        return database.deleteDatabase();
    }
}
